<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <!-- 引入 react 核心库-->
    <script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
    <!-- 引入 react-dom 用于支持操作 dom -->
    <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
    <!-- 引入 babel， 用于将jsx转为js -->
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

</head>
<body>
    <!-- 准备一个容器 , 用react渲染-->
    <div id = "root"></div>

    <div id = "dateTime"></div>
    
    <div id = "second"></div>
    <script type="text/babel">
        // 虚拟dom的两种创建方式
        // 1. 创建虚拟DOM
        const VDOM = <h1>Hello, React!</h1>;
        // 使用react 将虚拟dom转为真实dom
        ReactDOM.render(VDOM, document.getElementById('root'));

        function tick(){
            const VTime = <h1>{new Date().toLocaleTimeString()}</h1>
            ReactDOM.render(VTime, document.getElementById('dateTime'));
        }
        setInterval(tick, 1000)

        // 2. 创建虚拟DOM ==> 较为复杂
        const VSecond =React.createElement('h1',{id:'title'},
                        React.createElement('span',null,"第二种创建虚拟DOM"))
        ReactDOM.render(VSecond,document.getElementById('second'))
    </script>
</body>
</html>